<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>JQuery resize</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../../../libs/jquery/3.2.1/jquery.js"></script>
    <style>
        #my{
            width:100px;
            height: 100px;
            background-color: beige;
            border: 1px solid;
        }
    </style>
    <script>
        class Res
        var my_el;
        var resize_timer;
        $(document).ready(function(){
            my_el = $('#my');
            my_el._prevWidth = my_el.width();
            my_el._prevHeight = my_el.height();
            resize_timer = window.requestAnimationFrame(onMyReSize);
        })
        function onMyReSize(){
            let width = my_el.width();
            let height = my_el.height();
            if (width != my_el._prevWidth || height != my_el._prevHeight){
                my_el._prevWidth = width;
                my_el._prevHeight = height;
                console.log([width, height]);
            }
            requestAnimationFrame(onMyReSize);
        }
        function resizeDiv(oid){
            let el = $('#my');
            el.css('width', el.width()+1);
        }
    </script>
</head>
<body>
    <div id="my"></div>
    <button onclick="resizeDiv('#my')">调整大小</button>
</body>
</html>